package cn.tedu.service;

import cn.tedu.dao.DistrictMapper;
import cn.tedu.entity.Area;
import cn.tedu.entity.City;
import cn.tedu.entity.Province;
import cn.tedu.service.ex.SiteNotFoundExcption;
import cn.tedu.service.port.DistrictService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("districtService")
public class DistrictServiceImpl implements DistrictService {

    @Resource
    private DistrictMapper districtMapper;

    /**
     * 查找省列表
     * @return  返回省列表集合
     * @throws SiteNotFoundExcption 自定义地址信息异常错误
     */
    public List<Province> getProvince() throws SiteNotFoundExcption {
        return districtMapper.getProvince();
    }

    /**
     * 查找市列表
     * @param provinceCode  省代号
     * @return  返回市列表集合
     * @throws SiteNotFoundExcption 自定义地址信息异常错误
     */
    public List<City> getCity(String provinceCode) throws SiteNotFoundExcption {
        return districtMapper.getCity(provinceCode);
    }

    /**
     * 查找区列表
     * @param cityCode  市代号
     * @return  返回区列表集合
     * @throws SiteNotFoundExcption 自定义地址信息异常错误
     */
    public List<Area> getArea(String cityCode) throws SiteNotFoundExcption {
        return districtMapper.getArea(cityCode);
    }
}
